{
  "properties" : { },
  "id" : "2e2b7179c19b4a3e811b696da1a911b7",
  "script" : null,
  "groupId" : "74af8e1135d2474eb9b6b4081e6d5967",
  "name" : "查询已绑定的设备",
  "createTime" : 1727071038828,
  "updateTime" : 1726824926631,
  "lock" : "1",
  "createBy" : "ndmp",
  "updateBy" : "ndmp",
  "path" : "page",
  "method" : "POST",
  "parameters" : [ ],
  "options" : [ ],
  "requestBody" : "{\r\n    \"current\": 1,\r\n    \"size\": 30,\r\n    \"pageSize\": 1,\r\n    \"isLine\": 1,\r\n    \"id\": \"D5925903492352864794\",\r\n    \"groupId\": \"4\"\r\n}",
  "headers" : [ ],
  "paths" : [ ],
  "responseBody" : "{\n    \"status\": 200,\n    \"message\": \"success\",\n    \"data\": {\n        \"total\": 17,\n        \"current\": 1,\n        \"size\": 30,\n        \"records\": [\n            {\n                \"id\": \"D3336940152835154016\",\n                \"deviceName\": \"SN-CaoTanB.R1\",\n                \"ip\": \"61.2.8.8\",\n                \"stationProp\": \"4\",\n                \"deviceType\": \"1\",\n                \"netRegion\": \"1\",\n                \"groupName\": \"东郊变接入\",\n                \"rowId\": \"1\",\n                \"deviceTypeName\": \"路由器\",\n                \"stationValue\": \"接入\",\n                \"num\": 0\n            },\n            {\n                \"id\": \"D8584886695947961459\",\n                \"deviceName\": \"SN-HuXianQYB.R\",\n                \"ip\": \"61.2.8.19\",\n                \"stationProp\": \"4\",\n                \"deviceType\": \"1\",\n                \"netRegion\": \"1\",\n                \"groupName\": \"东郊变接入\",\n                \"rowId\": \"2\",\n                \"deviceTypeName\": \"路由器\",\n                \"stationValue\": \"接入\",\n                \"num\": 0\n            },\n            {\n                \"id\": \"D9136120488132190197\",\n                \"deviceName\": \"SN-DJBHJ.R1\",\n                \"ip\": \"61.2.8.1\",\n                \"stationProp\": \"3\",\n                \"deviceType\": \"1\",\n                \"netRegion\": \"1\",\n                \"groupName\": \"东郊变接入\",\n                \"rowId\": \"3\",\n                \"deviceTypeName\": \"路由器\",\n                \"stationValue\": \"汇聚\",\n                \"num\": 0\n            },\n            {\n                \"id\": \"D1343826793886305469\",\n                \"deviceName\": \"SN-SL.LongShanGF.R\",\n                \"ip\": \"61.2.8.22\",\n                \"stationProp\": \"4\",\n                \"deviceType\": \"1\",\n                \"netRegion\": \"1\",\n                \"groupName\": \"东郊变接入\",\n                \"rowId\": \"4\",\n                \"deviceTypeName\": \"路由器\",\n                \"stationValue\": \"接入\",\n                \"num\": 0\n            },\n            {\n                \"id\": \"D2704845107067673661\",\n                \"deviceName\": \"SNXA-NanJiaoB330.R\",\n                \"ip\": \"61.2.8.3\",\n                \"stationProp\": \"4\",\n                \"deviceType\": \"1\",\n                \"netRegion\": \"1\",\n                \"groupName\": \"东郊变接入\",\n                \"rowId\": \"5\",\n                \"deviceTypeName\": \"路由器\",\n                \"stationValue\": \"接入\",\n                \"num\": 0\n            },\n            {\n                \"id\": \"D2890815407246694602\",\n                \"deviceName\": \"SN-XA.HaoHeB.R\",\n                \"ip\": \"61.2.8.17\",\n                \"stationProp\": \"4\",\n                \"deviceType\": \"1\",\n                \"netRegion\": \"1\",\n                \"groupName\": \"东郊变接入\",\n                \"rowId\": \"6\",\n                \"deviceTypeName\": \"路由器\",\n                \"stationValue\": \"接入\",\n                \"num\": 0\n            },\n            {\n                \"id\": \"D5734336540563394608\",\n                \"deviceName\": \"SNXA-HeZhaiB330.R\",\n                \"ip\": \"61.2.8.6\",\n                \"stationProp\": \"4\",\n                \"deviceType\": \"1\",\n                \"netRegion\": \"1\",\n                \"groupName\": \"东郊变接入\",\n                \"rowId\": \"7\",\n                \"deviceTypeName\": \"路由器\",\n                \"stationValue\": \"接入\",\n                \"num\": 0\n            },\n            {\n                \"id\": \"D1916302732435321101\",\n                \"deviceName\": \"SN-WN.LingQuanB.R\",\n                \"ip\": \"61.2.8.27\",\n                \"stationProp\": \"4\",\n                \"deviceType\": \"1\",\n                \"netRegion\": \"1\",\n                \"groupName\": \"东郊变接入\",\n                \"rowId\": \"8\",\n                \"deviceTypeName\": \"路由器\",\n                \"stationValue\": \"接入\",\n                \"num\": 0\n            },\n            {\n                \"id\": \"D3384497016272117494\",\n                \"deviceName\": \"SNXA-DaiWangB330.R\",\n                \"ip\": \"61.2.8.9\",\n                \"stationProp\": \"4\",\n                \"deviceType\": \"1\",\n                \"netRegion\": \"1\",\n                \"groupName\": \"东郊变接入\",\n                \"rowId\": \"9\",\n                \"deviceTypeName\": \"路由器\",\n                \"stationValue\": \"接入\",\n                \"num\": 0\n            },\n            {\n                \"id\": \"D3390922460144027722\",\n                \"deviceName\": \"BeiJiaoB_XA_R\",\n                \"ip\": \"61.2.8.4\",\n                \"stationProp\": \"4\",\n                \"deviceType\": \"1\",\n                \"netRegion\": \"1\",\n                \"groupName\": \"东郊变接入\",\n                \"rowId\": \"10\",\n                \"deviceTypeName\": \"路由器\",\n                \"stationValue\": \"接入\",\n                \"num\": 0\n            },\n            {\n                \"id\": \"D7340796905432136447\",\n                \"deviceName\": \"SN-XiAnXingChengB.R\",\n                \"ip\": \"61.2.8.15\",\n                \"stationProp\": \"4\",\n                \"deviceType\": \"1\",\n                \"netRegion\": \"1\",\n                \"groupName\": \"东郊变接入\",\n                \"rowId\": \"11\",\n                \"deviceTypeName\": \"路由器\",\n                \"stationValue\": \"接入\",\n                \"num\": 0\n            },\n            {\n                \"id\": \"D1500891340818225077\",\n                \"deviceName\": \"SN-ChangLeB.R1\",\n                \"ip\": \"61.2.8.7\",\n                \"stationProp\": \"4\",\n                \"deviceType\": \"1\",\n                \"netRegion\": \"1\",\n                \"groupName\": \"东郊变接入\",\n                \"rowId\": \"12\",\n                \"deviceTypeName\": \"路由器\",\n                \"stationValue\": \"接入\",\n                \"num\": 0\n            },\n            {\n                \"id\": \"D7074767792745497512\",\n                \"deviceName\": \"SN-XA.LinXiB.R\",\n                \"ip\": \"61.2.8.25\",\n                \"stationProp\": \"4\",\n                \"deviceType\": \"1\",\n                \"netRegion\": \"1\",\n                \"groupName\": \"东郊变接入\",\n                \"rowId\": \"13\",\n                \"deviceTypeName\": \"路由器\",\n                \"stationValue\": \"接入\",\n                \"num\": 0\n            },\n            {\n                \"id\": \"D5606031178267445484\",\n                \"deviceName\": \"\",\n                \"ip\": \"61.2.8.26\",\n                \"stationProp\": \"4\",\n                \"deviceType\": \"1\",\n                \"netRegion\": \"1\",\n                \"groupName\": \"东郊变接入\",\n                \"rowId\": \"14\",\n                \"deviceTypeName\": \"路由器\",\n                \"stationValue\": \"接入\",\n                \"num\": 0\n            },\n            {\n                \"id\": \"D3751875766427246611\",\n                \"deviceName\": \"SNXA-NieLiuB330.R\",\n                \"ip\": \"61.2.8.11\",\n                \"stationProp\": \"4\",\n                \"deviceType\": \"1\",\n                \"netRegion\": \"1\",\n                \"groupName\": \"东郊变接入\",\n                \"rowId\": \"15\",\n                \"deviceTypeName\": \"路由器\",\n                \"stationValue\": \"接入\",\n                \"num\": 0\n            },\n            {\n                \"id\": \"D2559230509971040002\",\n                \"deviceName\": \"SNXA-ShangYuanB330.R\",\n                \"ip\": \"61.2.8.5\",\n                \"stationProp\": \"4\",\n                \"deviceType\": \"1\",\n                \"netRegion\": \"1\",\n                \"groupName\": \"东郊变接入\",\n                \"rowId\": \"16\",\n                \"deviceTypeName\": \"路由器\",\n                \"stationValue\": \"接入\",\n                \"num\": 0\n            },\n            {\n                \"id\": \"D5396082923046850980\",\n                \"deviceName\": \"SN-XX.YunGu330B.R\",\n                \"ip\": \"61.2.8.21\",\n                \"stationProp\": \"4\",\n                \"deviceType\": \"1\",\n                \"netRegion\": \"1\",\n                \"groupName\": \"东郊变接入\",\n                \"rowId\": \"17\",\n                \"deviceTypeName\": \"路由器\",\n                \"stationValue\": \"接入\",\n                \"num\": 0\n            }\n        ]\n    }\n}",
  "description" : "",
  "requestBodyDefinition" : {
    "name" : "",
    "value" : "",
    "description" : "",
    "required" : false,
    "dataType" : "Object",
    "type" : "",
    "defaultValue" : "",
    "validateType" : "",
    "error" : "",
    "expression" : "",
    "children" : [ {
      "name" : "current",
      "value" : "1",
      "description" : "",
      "required" : false,
      "dataType" : "Integer",
      "type" : "",
      "defaultValue" : "",
      "validateType" : "",
      "error" : "",
      "expression" : "",
      "children" : [ ]
    }, {
      "name" : "size",
      "value" : "30",
      "description" : "",
      "required" : false,
      "dataType" : "Integer",
      "type" : "",
      "defaultValue" : "",
      "validateType" : "",
      "error" : "",
      "expression" : "",
      "children" : [ ]
    }, {
      "name" : "pageSize",
      "value" : "1",
      "description" : "",
      "required" : false,
      "dataType" : "Integer",
      "type" : "",
      "defaultValue" : "",
      "validateType" : "",
      "error" : "",
      "expression" : "",
      "children" : [ ]
    }, {
      "name" : "isLine",
      "value" : "1",
      "description" : "",
      "required" : false,
      "dataType" : "Integer",
      "type" : "",
      "defaultValue" : "",
      "validateType" : "",
      "error" : "",
      "expression" : "",
      "children" : [ ]
    }, {
      "name" : "id",
      "value" : "D5925903492352864794",
      "description" : "",
      "required" : false,
      "dataType" : "String",
      "type" : "",
      "defaultValue" : "",
      "validateType" : "",
      "error" : "",
      "expression" : "",
      "children" : [ ]
    }, {
      "name" : "groupId",
      "value" : "4",
      "description" : "",
      "required" : false,
      "dataType" : "String",
      "type" : "",
      "defaultValue" : "",
      "validateType" : "",
      "error" : "",
      "expression" : "",
      "children" : [ ]
    } ]
  },
  "responseBodyDefinition" : {
    "name" : "",
    "value" : "",
    "description" : "",
    "required" : false,
    "dataType" : "Object",
    "type" : "",
    "defaultValue" : "",
    "validateType" : "",
    "error" : "",
    "expression" : "",
    "children" : [ {
      "name" : "status",
      "value" : "200",
      "description" : "",
      "required" : false,
      "dataType" : "Integer",
      "type" : "",
      "defaultValue" : "",
      "validateType" : "",
      "error" : "",
      "expression" : "",
      "children" : [ ]
    }, {
      "name" : "message",
      "value" : "success",
      "description" : "",
      "required" : false,
      "dataType" : "String",
      "type" : "",
      "defaultValue" : "",
      "validateType" : "",
      "error" : "",
      "expression" : "",
      "children" : [ ]
    }, {
      "name" : "data",
      "value" : "",
      "description" : "",
      "required" : false,
      "dataType" : "Object",
      "type" : "",
      "defaultValue" : "",
      "validateType" : "",
      "error" : "",
      "expression" : "",
      "children" : [ {
        "name" : "total",
        "value" : "2",
        "description" : "",
        "required" : false,
        "dataType" : "Integer",
        "type" : "",
        "defaultValue" : "",
        "validateType" : "",
        "error" : "",
        "expression" : "",
        "children" : [ ]
      }, {
        "name" : "current",
        "value" : "1",
        "description" : "",
        "required" : false,
        "dataType" : "Integer",
        "type" : "",
        "defaultValue" : "",
        "validateType" : "",
        "error" : "",
        "expression" : "",
        "children" : [ ]
      }, {
        "name" : "size",
        "value" : "30",
        "description" : "",
        "required" : false,
        "dataType" : "Integer",
        "type" : "",
        "defaultValue" : "",
        "validateType" : "",
        "error" : "",
        "expression" : "",
        "children" : [ ]
      }, {
        "name" : "records",
        "value" : "",
        "description" : "",
        "required" : false,
        "dataType" : "Array",
        "type" : "",
        "defaultValue" : "",
        "validateType" : "",
        "error" : "",
        "expression" : "",
        "children" : [ {
          "name" : "",
          "value" : "",
          "description" : "",
          "required" : false,
          "dataType" : "Object",
          "type" : "",
          "defaultValue" : "",
          "validateType" : "",
          "error" : "",
          "expression" : "",
          "children" : [ {
            "name" : "id",
            "value" : "D1814237884760947677",
            "description" : "",
            "required" : false,
            "dataType" : "String",
            "type" : "",
            "defaultValue" : "",
            "validateType" : "",
            "error" : "",
            "expression" : "",
            "children" : [ ]
          }, {
            "name" : "deviceName",
            "value" : "SN2.BD.R1",
            "description" : "",
            "required" : false,
            "dataType" : "String",
            "type" : "",
            "defaultValue" : "",
            "validateType" : "",
            "error" : "",
            "expression" : "",
            "children" : [ ]
          }, {
            "name" : "ip",
            "value" : "2.61.0.2",
            "description" : "",
            "required" : false,
            "dataType" : "String",
            "type" : "",
            "defaultValue" : "",
            "validateType" : "",
            "error" : "",
            "expression" : "",
            "children" : [ ]
          }, {
            "name" : "stationProp",
            "value" : "1",
            "description" : "",
            "required" : false,
            "dataType" : "String",
            "type" : "",
            "defaultValue" : "",
            "validateType" : "",
            "error" : "",
            "expression" : "",
            "children" : [ ]
          }, {
            "name" : "deviceType",
            "value" : "1",
            "description" : "",
            "required" : false,
            "dataType" : "String",
            "type" : "",
            "defaultValue" : "",
            "validateType" : "",
            "error" : "",
            "expression" : "",
            "children" : [ ]
          }, {
            "name" : "netRegion",
            "value" : "1",
            "description" : "",
            "required" : false,
            "dataType" : "String",
            "type" : "",
            "defaultValue" : "",
            "validateType" : "",
            "error" : "",
            "expression" : "",
            "children" : [ ]
          }, {
            "name" : "groupName",
            "value" : "test2324",
            "description" : "",
            "required" : false,
            "dataType" : "String",
            "type" : "",
            "defaultValue" : "",
            "validateType" : "",
            "error" : "",
            "expression" : "",
            "children" : [ ]
          }, {
            "name" : "rowId",
            "value" : "1",
            "description" : "",
            "required" : false,
            "dataType" : "String",
            "type" : "",
            "defaultValue" : "",
            "validateType" : "",
            "error" : "",
            "expression" : "",
            "children" : [ ]
          }, {
            "name" : "deviceTypeName",
            "value" : "路由器",
            "description" : "",
            "required" : false,
            "dataType" : "String",
            "type" : "",
            "defaultValue" : "",
            "validateType" : "",
            "error" : "",
            "expression" : "",
            "children" : [ ]
          }, {
            "name" : "stationValue",
            "value" : "骨干",
            "description" : "",
            "required" : false,
            "dataType" : "String",
            "type" : "",
            "defaultValue" : "",
            "validateType" : "",
            "error" : "",
            "expression" : "",
            "children" : [ ]
          }, {
            "name" : "num",
            "value" : "0",
            "description" : "",
            "required" : false,
            "dataType" : "Integer",
            "type" : "",
            "defaultValue" : "",
            "validateType" : "",
            "error" : "",
            "expression" : "",
            "children" : [ ]
          } ]
        } ]
      } ]
    } ]
  }
}
================================
import java.lang.reflect.Array
import org.springblade.common.cache.DictCache
import java.util.function.Function
import java.util.stream.Collectors
import java.lang.Integer


import org.springframework.util.CollectionUtils



var page = db.page("""
  select * from (
        SELECT
            d.id,
            d.device_name,
            d.ip,
            d.station_prop,
            d.device_type,
            d.net_region,
            grou.group_name
        FROM
            ndmp_group_device_relation dr
        LEFT JOIN ndmp_device d ON dr.device_id = d.id
        left join NDMP_GROUP grou on grou.ID = dr.GROUP_ID
        <where>
            <if test="body.deviceType!=null and body.deviceType!=''">
                AND  d.device_type= #{body.deviceType}
            </if>
            <if test="body.groupId!=null and body.groupId!=''">
                AND  dr.group_id= #{body.groupId}
            </if>
            <if test="body.deviceName!=null and body.deviceName!=''">
                AND d.DEVICE_NAME like concat('%',#{body.deviceName},'%')
            </if>

            <if test="body.ip!=null and body.ip!=''">
                AND d.ip like concat('%',#{body.ip},'%')
            </if>
            <if test="body.deptId!=null and body.deptId!=''">
                AND grou.ID =#{body.deptId}
            </if>
            <if test="body.stationProp!=null and body.stationProp!=''">
                AND d.station_prop =#{body.stationProp}
            </if>
            <if test="body.isLine==1">
                AND d.id != #{body.id}
            </if>
        </where>
) where id is not null
  """)

List ipCharts = db.select("""
       select target_deviceid,count(target_deviceid) sum  from NET_DEVICE_LINK_CHART
       where device_id=#{body.id}  group by target_deviceid
        """)


HashMap map = new HashMap(32);
ipCharts.stream().forEach(e -> {
    map.put(e.get("targetDeviceid"), e.get("sum"));
});

List res = page.get("records")
if (CollectionUtils.isEmpty(res)) {
    page.put("records", new ArrayList());
    return page
}

//  Map mergedMap = res.stream()
//      .collect(Collectors.toMap(
//          v -> v.get("id"), // 用于分组的 key
//          Function.identity(), // 映射为 Device 对象
//          (existing, replacement) -> { // 合并策略
//              existing.put("groupName", (existing.get("groupName") + "," + replacement.get("groupName")));
//              return existing;
//          },
//          HashMap::new // 创建一个新的 HashMap
//      ));

//  res = mergedMap.values().stream().collect(Collectors.toList());

for (v in res) {
    if (null == v) {
        continue;
    }

    v.put("deviceTypeName", DictCache.getValue("deviceType", v.get("deviceType")::int));
    v.put("stationValue", DictCache.getValue("stationProp", v.get("stationProp")::int));
    Integer num = map.get(v.get("id")) == null ? 0 : map.get(v.get("id"));
    v.put("num", num);
}
page.put("records", res);
return page